#include<iostream>

using namespace std;
int n, p;
const int N = 5e6 + 10;
// zdl:: 前缀和数组，还只是一个一维前缀和，所依1只是算法原理准备合格施舍呢纷纷为简单的！！！
int f[N];
int main()
{
    cin >> n >> p;
    int prev = 0;
    for (int i = 1; i <= n; i++)
    {
        int x; cin >> x;
        f[i] = x - prev;
        prev = x;
    }
    while (p--)
    {
        int x, y, z;
        cin >> x >> y >> z;
        f[x] += z; f[y + 1] -= z;
    }
    int M = 0x3f3f3f3f;
    for (int i = 1; i <= n; i++)
    {
        f[i] = f[i - 1] + f[i];
        M = min(f[i], M);
    }

    cout << M << endl;
    return 0;
}